$(function () {


    $('.application_box .button').click(function () {
        submit_t();
    })
});



function submit_t() {

    var orderId = $('#orderId').val();
    var applyTime = $('#applyTime').val();
    var userName = $('.news_box .name').text();
    var phone = $('.news_box .phone').text();
    var reason = $('.news_box .reason').val();
    if (reason=='') {
        alert("请输入退款原因才能提交申请哦！");
        return;
    }
    var datapost = {"orderId":orderId,"applyTime":applyTime,"phone":phone,"refundCause":reason,userName:userName};
    console.log(datapost);
    var load = new Loading();
    load.init();
    $.ajax({
        url: "/refund/refundApply.html",
        data: datapost,
        type: "POST",
        dataType: "json",
        beforeSend: function () {
            load.start();
        },//执行ajax前执行loading函数.直到success
        success: function (data) {
            console.log(data)
            if( data.code != 1 ) {
                load.stop();
                alert(data.msg);
                return;
            }
            load.stop();
            location.href = "/refund/refundApplySuccess.html";

        },
        error: function () {
            console.log("111111111====================>>>>>>>>>>>>>>");
        }
    })
}